package lab02.test03;

public class Student {

    //1.属性
    String name;
    int age;
    String num;
    String sex;
    String faculty;     //院系
    String classes;
    float computerscore;
    float mathscore;
    float englishscore;
    float totalscore;
    float averagescore;
    float maxscore;
    float minscore;

    //2.方法
    public void totalScore() {
        totalscore = computerscore + mathscore + englishscore;
        System.out.println("总分 = " + totalscore);
    }

    public void averageScore() {
        averagescore = (computerscore + mathscore +englishscore)/3;
        System.out.println("平均分 = " + averagescore);
    }

    public void maxScore() {
        maxscore = max(computerscore,mathscore);
        maxscore = max(maxscore,englishscore);
        System.out.printf("最高分 = " + maxscore);
    }

    public void minScore() {
        minscore = min(computerscore,mathscore);
        minscore = min(minscore,englishscore);
        System.out.println("最低分 = " + minscore);
    }

    public float max(float a,float b) {
        float max;
        if (a>b) {
            max = a;
        }else {
            max = b;
        }
        return max;
    }

    public float min(float a,float b) {
        float min;
        if (a>b) {
            min = b;
        }else {
            min = a;
        }
        return min;
    }

    //3.构造函数
    Student() {}

    @Override
    public String toString() {
        return "学号:" + num + "\n" + "姓名:" + name + "\n" + "性别:" + sex + "\n" +
                "年龄:" + age + "\n" + "性别:" + sex + "院系:" + faculty + "\n" + "班级:" + classes +
                "计算机成绩:" + computerscore + "\n" + "数学成绩:" + mathscore + "\n" +
                "英语成绩:" + englishscore;
    }
}
